//
//  LYEmoticonButton.swift
//  EmoticonKeyboard
//
//  Created by liuerying on 16/5/31.
//  Copyright © 2016年 liuerying. All rights reserved.
//

import UIKit

class LYEmoticonButton: UIButton {

    var  emoticon: LYEmoticon?{
    
        didSet{
        
            if let imagePath = emoticon?.imagePath{
            
                setImage(UIImage(named: imagePath), forState: .Normal)
                setTitle(nil, forState: .Normal)
            }else{
            
                if let title = emoticon?.emoji{
                
                    setTitle(title, forState: .Normal)
                    setImage(nil, forState: .Normal)
                }
            }
            
            if emoticon!.isDelete{
            
                setImage(UIImage(named:"compose_emotion_delete" ), forState: .Normal)
            }
            
            if emoticon!.isEmpty{
            
                setTitle(nil, forState: .Normal)
                setImage(nil, forState: .Normal)
            }

        }
    }
    

    
    

}
